package com.abc.pro.model;

public abstract class Event {
    // Competition info
    protected long competitionID;
    protected String competitionName;
    protected EventInfo mInfo;
    
    protected EventType.O1x2[] m1x2;
    protected EventType.Ah[] mAh;
    protected EventType.Ou[] mOu;
    
    public Event(long id, String name) {
        competitionID = id;
        competitionName = name;
    }
    
    public Event(long id, String name, EventInfo info) {
        competitionID = id;
        competitionName = name;
        mInfo = info;
    }
    
    public long getCompetitionId() {
        return competitionID;
    }

    public void setCompetitionId(long id) {
        this.competitionID = id;
    }

    public String getCompetitionName() {
        return competitionName;
    }

    public void setCompetitionName(String name) {
        this.competitionName = name;
    }

    public EventInfo getInfo() {
        return mInfo;
    }

    public void setInfo(EventInfo info) {
        this.mInfo = info;
    }
    
    public long getMatchId(){
        return mInfo.id;
    }
    
    public String getMatchDate(){
        return mInfo.iDate;
    }
    
    public String getMatchTime(){
        return mInfo.iTime;
    }
    
    public String getHomeTeam(){
        return mInfo.iHomeTeam;
    }
    
    public String getAwayTeam(){
        return mInfo.iAwayTeam;
    }
    
    public EventType.O1x2[] get1x2() {
        return m1x2;
    }
    
    public void set1x2(EventType.O1x2[] m1x2) {
        this.m1x2 = m1x2;
    }
    
    public EventType.Ah[] getAh() {
        return mAh;
    }
    
    public void setAh(EventType.Ah[] asianHan) {
        this.mAh = asianHan;
    }
    
    public EventType.Ou[] getOu() {
        return mOu;
    }
    
    public void setOu(EventType.Ou[] overUnder) {
        this.mOu = overUnder;
    }
    
    public abstract int getCount();
    
    public void updateRowData(OddRow row, int line){
        row.setHomeTeam(mInfo.iHomeTeam);
        row.setAwayTeam(mInfo.iAwayTeam);
        int i = line;
        
        if(m1x2 != null && i < m1x2.length){
            row.setFull1x2Result(m1x2[i].homeWinvalue);
            row.setFull1x2Home(m1x2[i].awayWinValue);
            row.setFull1x2Away(m1x2[i].drawValue);
        }
        
        if(mAh != null && i < mAh.length){
            row.setFullhdp1(getAbsStr(mAh[i].homeValue));
            row.setFullhdp2_1(mAh[i].homeOddsValue);
            row.setFullhdp2_2(mAh[i].awayOddsValue);
        }

        if(mOu != null && i < mOu.length){
            row.setFullou1(getAbsStr(mOu[i].overValue));
            row.setFullou2_1(mOu[i].overOddsValue);
            row.setFullou2_2(mOu[i].underOddsValue);
        }
    }
    
    protected String getAbsStr(String value){
        return value.replace("-", "").replace("+", "");
    }
}
